'''
dict_keys(['infos', 'metadata'])  # 标注信息，版本号

infos: ['lidar_path', 'token', 'sweeps', 'cams', 
        'lidar2ego_translation', 'lidar2ego_rotation', 'ego2global_translation', 
        'ego2global_rotation', 'timestamp', 
        'gt_boxes', 'gt_names', 'gt_velocity', 
        'num_lidar_pts', 'num_radar_pts', 'valid_flag', 
        'ann_infos', 'scene_token', 'occ_path']

    lidar_path: 相对路径
    toke: ca9a282c9e77460f8360f564131a8af5
    sweeps: [] 空的
    cams: ['CAM_FRONT', 'CAM_FRONT_RIGHT', 'CAM_FRONT_LEFT', 'CAM_BACK', 'CAM_BACK_LEFT', 'CAM_BACK_RIGHT']
        cams["CAM_FRONT"]: ['data_path', 'type', 'sample_data_token', 
                            'sensor2ego_translation', 'sensor2ego_rotation', 'ego2global_translation', 
                            'ego2global_rotation', 'timestamp', 'sensor2lidar_rotation', 
                            'sensor2lidar_translation', 'cam_intrinsic']
            data_path: 相对路径
            type: 相机名称
            cam_intrinsic: 3x3
            ego2global_rotation: 4 
            sensor2lidar_translation: 3 
            sample_data_tok: e3d495d4ac534d54b321f50006683844
            timestamp: 1532402927612460  16位

    lidar2ego_translation: 四元素 4维
    lidar2ego_rotation:    平移 3维
    timestamp: 1532402927647951    16位 

    gt_boxes: [n个[x,y,z,dx,dy,dz,yaw]]  nx7
    gt_names: n  [n个name]                n
    gt_velocity: [n个[vx, vy]]           nx2
    
    num_lidar_pts:  每个框的lidar点数
    num_radar_pts:  每个框的radar点数
    valid_flag:     是否有效  
    scene_token: 场景token
    occ_path: occ路径
    ann_infos: [[box带速度  n * 9],[name_id * n]]

            
'''

['frame_id', 'lidar_path', 'token', 'sweeps', 'cams', 'lidar2ego_translation', 
 'lidar2ego_rotation', 'timestamp', 'valid_flag', 'scene_token', 
 'occ_path', 'ann_infos', 
 'gt_boxes', 'gt_names', 'num_lidar_pts', 'is_2d_visible', 'num_radar_pts']

from mmengine import load
import numpy as np

info_path4 = "/home/lin/code/bevdetv2.1/BEVDet/data/nuscenes/bevdetv2-nuscenes_infos_train.pkl"
# info_path4 = "/home/lin/code/bevdetv2.1/BEVDet/data/kitti/custom_infos_train.pkl"

info_file = load(info_path4)

print(info_file.keys())
print(info_file['metadata'])

for sample in info_file['infos']:
    print(sample.keys())
    print("\n")
    print(sample['cams'].keys())
    print(sample['cams']['CAM_FRONT'].keys())
    
    print(sample['cams']['CAM_FRONT']["data_path"])
    print(sample['cams']['CAM_FRONT']["type"])
    print(sample['cams']['CAM_FRONT']["ego2global_rotation"])
    print(sample['cams']['CAM_FRONT']["sensor2lidar_translation"])
    print(sample['cams']['CAM_FRONT']["sample_data_token"])
    print(sample['cams']['CAM_FRONT']["timestamp"])

    print(sample['token'])
    print(sample['sweeps'])
    print(sample['lidar2ego_rotation'])
    print(sample['lidar2ego_translation'])
    print(sample['timestamp'])

    # print(sample['gt_boxes'])
    print(sample['gt_names'])
    
    print("gt_velocity: ", sample['gt_velocity'])

    print(len(sample['gt_names']))
    print(len(sample['valid_flag']))
    

    print(sample['valid_flag'])
    print("valid_flag': ", len(sample['valid_flag']))
    
    false_count = np.size(sample['valid_flag']) - np.count_nonzero(sample['valid_flag'])
    
    print(false_count)

    print(sample['ann_infos'])
    print()

    # print(sample['num_lidar_pts'])
    # print(len(sample['num_lidar_pts']))

    # print(sample['num_radar_pts'])
    # print(len(sample['num_radar_pts']))
    
    # print(sample['scene_token'])
    # print(sample['occ_path'])

    print((len(sample['ann_infos'][0])))
    print((sample['ann_infos'][1]))
    print((len(sample['ann_infos'][1])))

    # print(sample['ann_infos'][0][0])


    # print(sample['gt_boxes'])
    # print(sample['gt_velocity'][4])
    # print(sample['ann_infos'][0][4])
    

    break